/**
* Copyright (c) 2022 - present TinyVue Authors.
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

@import '../mixins/hairline.less';
@import '../custom.less';
@import './vars.less';

@tabs-prefix-cls: ~'@{css-prefix}mobile-tabs';

.@{tabs-prefix-cls} {
  position: relative;

  &__header {
    overflow: hidden;
    background: var(--ti-mobile-tabs-bgcolor, #fff);
    position: relative;
    .hairline('bottom', var(--ti-mobile-tabs-border-color, #ccc));

    &.is-double-border {
      .hairline('top', var(--ti-mobile-tabs-border-color, #ccc));
    }
  }

  &__content {
    overflow: hidden;
    font-size: var(--ti-mobile-tabs-font-size, 14px);
    color: var(--ti-mobile-tabs-color, #333);
    background: var(--ti-mobile-tabs-bgcolor, #fff);
    padding: 15px 24px;
  }

  &__new-tab {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: var(--ti-mobile-tabs-new-tab-width, 44px);
    display: flex;
    justify-content: center;
    align-items: center;

    &:focus {
      outline: 0;
    }

    svg {
      font-size: var(--ti-mobile-tabs-icon-font-size, 24px);
      fill: var(--ti-mobile-tabs-icon-color, #bbb);
    }
  }

  &__new-tab + &__nav-wrap {
    width: calc(100% - var(--ti-mobile-tabs-new-tab-width, 44px));
  }

  &__nav-wrap {
    position: relative;
  }

  &__nav-wrap&__wrap-scrollable {
    .@{tabs-prefix-cls}__item {
      flex: 0 0 22%;
    }

    .@{tabs-prefix-cls}__nav {
      overflow: hidden;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;

      &::-webkit-scrollbar {
        display: none;
      }
    }
  }

  &__nav {
    white-space: nowrap;
    position: relative;
    transition: transform 0.3s;
    display: flex;
  }

  &__item {
    position: relative;
    flex: 1;
    box-sizing: border-box;
    text-align: center;
    height: var(--ti-mobile-tabs-header-height, 40px);
    line-height: var(--ti-mobile-tabs-header-height, 40px);
    font-size: var(--ti-mobile-tabs-font-size, 14px);
    color: var(--ti-mobile-tabs-color, #333);
    cursor: pointer;
    transition: all 0.3s ease-in-out 0s;
  }

  &__name {
    display: inline-block;
    padding: 0px 10px;
  }

  &__item.is-active &__name {
    color: var(--ti-mobile-tabs-active-color, #f36f64);
    position: relative;
  }

  &__line {
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 1;
    width: 40px;
    height: 2px;
    background-color: var(--ti-mobile-tabs-active-color, #f36f64);
    border-radius: 3px;
    transition-duration: 0.3s;
  }

  &__more-container {
    position: absolute;
    top: 0;
    right: 0;
  }

  &__more {
    display: block;
    font-size: 14px;
    height: 40px;
    line-height: 40px;
    width: 48px;
    text-align: center;
    background: #fff;
    z-index: 9999;
    color: #f36f64;
  }

  &__more-list {
    position: absolute;
    top: 42px;
    overflow-y: scroll;
    z-index: 9999;
    border: 1px solid #ccc;
    border-radius: 5px;
    right: 0px;
    padding: 10px;
    background: #fff;
  }

  &__more-item {
    height: 30px;
    line-height: 30px;
    min-width: 50px;
    text-align: center;
    font-size: 14px;
    color: #333;

    &:focus {
      outline: 0;
    }
  }

  &__icon-close {
    margin-left: 5px;
  }

  &__nav-wrap-children &__name {
    height: 20px;
    line-height: 20px;
    min-width: 60px;
    border-radius: 20px;
    padding: 0px 12px;
    font-size: 14px;
    color: var(--ti-mobile-tabs-children-color, #000);
    border: 1px solid var(--ti-mobile-tabs-children-border-color, #eee);
  }

  &__nav-wrap-children &__item.is-active &__name {
    border: 1px solid var(--ti-mobile-tabs-active-color, #f36f64);
    color: var(--ti-mobile-tabs-active-color, #f36f64);

    &:after {
      border-bottom: 0;
    }
  }

  &__nav-wrap-children &__nav &__item {
    width: auto;
    margin-left: 10px;

    &:first-child {
      margin-left: 0px;
    }
  }

  &__more-popover {
    position: fixed;
    right: 0px;

    ul {
      display: block;
      position: absolute;
      width: 200px;
      right: 0px;
      min-width: 150px;
      background: #fff;
      top: 40px;
      border-radius: 5px;
      border: 1px solid #ccc;
    }
  }

  &__more-item {
    height: 30px;
    line-height: 30px;
    font-size: 14px;

    &:hover {
      color: #f36f64;
    }
  }
}
